package com.bdqn.ordersystem.utils;

import java.util.List;

public class Pager<T> {
	
	private int pageIndex;//当前页码
	private int pageSize;//一页显示多少个
	private int totalCount;//总条目数
	private List<T> list;//对象集合
	private int totalPages;
	private boolean hasPrevPage;
	private boolean hasNextPage;
	
	public int getPageIndex() {
		return pageIndex;
	}
	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	/**
	 * 获取页码数
	 * @return
	 */
	public int getTotalPages() {
		return (this.totalCount%this.pageSize==0)? this.totalCount/this.pageSize : this.totalCount/this.pageSize+1;
	}
	public List<T> getList() {
		return list;
	}
	public void setList(List<T> list) {
		this.list = list;
	}
	public boolean getHasPrevPage() {
		return this.pageIndex > 1;
	}
	public boolean getHasNextPage() {
		return this.pageIndex < this.getTotalPages();
	}
	
	
}
